'use strict';

const { ErrorModel } = require('../utils/ResModel');
const { jsonRulesFileInfo } = require('../utils/ErrorModel');

module.exports = () => {
  return async (ctx, next) => {
    const data = ctx.request.body;
    await ctx.validate('schema.user', data).then(async () => {
      await next();
    }).catch(async () => {
      ctx.body = new ErrorModel(jsonRulesFileInfo);
      return;
    });
  };
};

